home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1987 July
/
Ahoy_Magazine_87-07_1987_Double_L_Side_A.d64
/
Bmap Tutorial
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
2KB
|
72 lines
1 rem bit map tutorial
2 rem with color
3 rem by
4 rem morton kevelson
10 poke 56578,peek(56578) or 3:rem set cia for output
15 a=0:rem video bank 3 ($c000-$ffff)
20 poke 56576,(peek(56576) and 252) or a:rem select video bank
30 poke 53265,peek(53265) or 32:rem set hi-res
40 os=peek(53272):rem store original screen location
50 poke 53272,peek(53272) or 8:rem set bit map offset to 8192
60 poke 53272,peek(53272) and 15:rem set screen offset to 0
70 bm=57344:rem start of bit map
80 sm=49152:rem start of screen
90 cm=55296:rem start of color mem
100 bg=53281:rem bground for multicolor
105 hn=0:ln=1:cn=6:bc=14:sc=hn*16+ln:rem start colors
110 for i=0 to 999:rem clear screen and set colors
120 poke sm+i,sc:rem set screen colors
130 poke cm+i,cn:rem set color mem
140 next i
150 poke bg,bc:rem set bground color
160 for i=0 to 7999:rem clear bit map
170 poke bm+i,0
180 next i
190 r1=11:rem start screen row
200 r2=14:rem end screen row
210 c1=18:c2=22:rem start & end column
220 nb=(c2-c1)*8+7:rem number of bytes per row
230 rem fill patterns
235 data 102,68,85,170,204,99
240 cn=6:ct=cn:rem number of fill patterns
250 read pt:ct=ct-1:if ct=0 then ct=cn:restore
260 gosub 1000
270 gosub 2000
280 goto 250
1000 for ro=r1 to r2:rem fill with pattern
1010 fi=bm+ro*320+c1*8:rem calc first row byte
1020 for j=0 to nb:rem fill row
1030 poke fi+j,pt
1040 next j
1050 next ro
1060 return
2000 get a$
2010 if a$="[133]" then poke 53270,peek(53270) and 239:rem f1=hi-res
2020 if a$="[134]" then poke 53270,peek(53270) or 16:rem f3=multi-color
2030 if a$="[135]" then return:rem f5=get next pattern
2040 if a$="[136]" goto 3000:rem f7=quit
2050 if a$="[137]" then mm=sm:gosub4000:gosub4100:rem hi-nybble
2060 if a$="[138]" then mm=sm:gosub4020:gosub4100:rem lo-nybble
2070 if a$="[139]" then mm=cm:gosub4040:gosub4100:rem color mem
2080 if a$="[140]" then gosub4060:rem bground nybble
2090 goto2000
3000 poke 56576,(peek(56576) and 252) or 3:rem restore text display
3010 poke 53265,(peek(53265) and 223)
3020 poke 53270,peek(53270) and 239
3030 poke 53272,os:poke bg,6:for i=0 to 999:poke cm+i,14:next i
3040 end
4000 hn=hn+1:if hn>15 then hn=0
4010 cv=hn*16+ln:return
4020 ln=ln+1:if ln>15 then ln=0
4030 goto 4010
4040 cn=cn+1:if cn>15 then cn=0:cv=0:return
4050 cv=cn:return
4060 bc=bc+1:if bc>15 then bc=0
4070 poke bg,bc:return
4100 for ro=r1 to r2
4110 fs=mm+ro*40+co
4120 for cb=c1 to c2
4130 poke fs+cb,cv
4140 next cb:next ro
4150 return